package com.syyo.gulimall.product.app;

//import org.springframework.security.access.prepost.PreAuthorize;
import com.syyo.common.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.syyo.gulimall.product.domain.req.SpuImagesReq;
import com.syyo.gulimall.product.service.SpuImagesService;
import com.syyo.common.domain.ResultVo;


/**
 * spu图片
 *
 * @author syyo
 * @email syyo@gmail.com
 * @date 2021-01-20 09:32:12
 */
@RestController
@RequestMapping("/product/spuimages")
public class SpuImagesController {

    @Autowired
    private SpuImagesService spuImagesService;

    /**
    * 新增
    */
    @PostMapping
    // @PreAuthorize("@syyo.check('system:spuimages:add')")
    public ResultVo add(@RequestBody SpuImagesReq req){
        return ResultUtils.ok(spuImagesService.add(req));
    }

    /**
 * 删除
 */
    @DeleteMapping("/{id}")
    // @PreAuthorize("@syyo.check('system:spuimages:del')")
    public ResultVo del(@PathVariable("id") Integer id){
        return ResultUtils.ok(spuImagesService.del(id));
    }

    /**
   * 修改
   */
    @PutMapping
    // @PreAuthorize("@syyo.check('system:spuimages:edit')")
    public ResultVo edit(@RequestBody SpuImagesReq req){
        return ResultUtils.ok(spuImagesService.edit(req));
    }

    /**
     * 信息
     */
    @GetMapping("/{id}")
    public ResultVo findOne(@PathVariable("id") Integer id){
        return ResultUtils.ok(spuImagesService.findOne(id));
    }

    /**
      * 列表
      */
    @GetMapping("/list/{pageNum}/{pageSize}")
    public ResultVo findAll(@PathVariable("pageNum") Integer pageNum,
                            @PathVariable("pageSize") Integer pageSize,
                            SpuImagesReq req){
        return ResultUtils.ok(spuImagesService.findAll(pageNum,pageSize,req));
    }

}
